#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
from PySide import QtGui
from eqspy import Ui_EQSignal as Ui_EQSignal

def EQUI():
    # Avoiding errors in interactive mode (eg. IPython)
    appinstance = QtGui.QApplication.instance()
    if appinstance is None:
        app = QtGui.QApplication(sys.argv)
    else:
        app = appinstance

    font = QtGui.QFont()
    font.setFamily("Microsoft YaHei")
    font.setPointSize(10)
    font.setWeight(50)
    font.setBold(False)
    app.setFont(font)

    ue = Ui_EQSignal()
    # ue.fileName = "data/CHICHI04-CHY039-N.at2"
    # ue.eqs.readNGAFile(ue.fileName)
    # ue.eqs.norm()
    # ue.plotTH()
    # ue.tabWidget.setCurrentIndex(0)
    # ue.VDTH.setEnabled(True)
    # ue.setDefaultValue()

    # ue.calSPthenPlotSP()

    return app, ue

def main():

    # Avoiding errors in interactive mode (eg. IPython)
    appinstance = QtGui.QApplication.instance()
    if appinstance is None:
        app = QtGui.QApplication(sys.argv)
    else:
        app = appinstance

    font = QtGui.QFont()
    font.setFamily("Microsoft YaHei")
    font.setPointSize(10)
    font.setWeight(50)
    font.setBold(False)
    app.setFont(font)

    ue = Ui_EQSignal()
    ue.fileName = "data/CHICHI04-CHY039-N.at2"
    ue.eqs.readNGAFile(ue.fileName)
    ue.eqs.norm()
    ue.plotTH()
    ue.tabWidget.setCurrentIndex(0)
    ue.VDTH.setEnabled(True)
    ue.setDefaultValue()

    ue.calSPthenPlotSP()

    ue.show()
    sys.exit(app.exec_())

if __name__ == '__main__':

    # main()
    app, ue = EQUI()
    ue.show()
    app.exec_()
